<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');


/**
 *
 *
 *
 * @package     h
 * @subpackage  models
 * @category    models
 * @author      hyw
 * @copyright   copyright (c) 2012
 * @filesource
 */


class Check_model extends CI_model {

    protected $_table_name = '';
    protected $_key_name = '';
	
    function set_table_name($name) {
		$this->_table_name	=	$name;
    }

    function set_key_name($key_name) {
		$this->_key_name	=	$key_name;
    }
	
	function check_building_name_exist($table_field_name , $value ) {


		$this->db->where($table_field_name , $value);
		$query=$this->db->get($this->_table_name);

		if ($query->num_rows() > 0) {

			$row=$query->row();
			return $row->building_name_id;

		}else{

			$data = array(
			   'value' => $value ,
			   'explanation' => $value ,			  
			);

			$this->db->insert($this->_table_name , $data); 
			$this->db->where($table_field_name , $value);
			$query=$this->db->get($this->_table_name);
			$row=$query->row();
			return $row->building_name_id;

			//return false;

		}
		
    }
}